package com.app.backend.common.response;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.List;

/**
 * @program: TableResponse
 * @description:
 * @author: Zhun.Xiao
 * @create: 2018-11-22 21:27
 **/

@Getter
@Setter
public class TableResponse<T> extends BaseResponse {
    @Getter
    @Setter
    @AllArgsConstructor
    @NoArgsConstructor
    static class TableData<T> {
        long total;
        List<T> rows;
    }

    TableData<T> data;

    public TableResponse(long total, List<T> rows) {
        this.data = new TableData<T>(total, rows);
    }

    public TableResponse() {
        this.data = new TableData<T>();
    }

    TableResponse<T> total(int total) {
        this.data.setTotal(total);
        return this;
    }

    TableResponse<T> total(List<T> rows) {
        this.data.setRows(rows);
        return this;
    }


}
